package org.esk.dablog.web.forms.user;

import org.springframework.web.servlet.mvc.ParameterizableViewController;
import org.springframework.web.servlet.ModelAndView;
import org.esk.dablog.service.UserManager;
import org.esk.dablog.model.Author;
import org.esk.dablog.web.util.RequestUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * This class implements "View Profile" task
 * User: esk
 * Date: 10.12.2006
 * Time: 21:54:11
 * $Id:$
 */
public class ViewProfileForm extends ParameterizableViewController {

    private UserManager userManager;

    protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String username = RequestUtils.extractStringParameter(request);
        Author a = userManager.getAuthorByUsername(username);
        ModelAndView result = new ModelAndView(getViewName());
        result.addObject("command", a);
        return result;
    }


    public void setUserManager(UserManager userManager) {
        this.userManager = userManager;
    }
}
